package com.baizhi.service.impl;

import com.baizhi.dao.CmfzAlbumDao;
import com.baizhi.dao.CmfzArticleDao;
import com.baizhi.entity.CmfzAlbum;
import com.baizhi.entity.CmfzArticle;
import com.baizhi.service.AlbumService;
import com.baizhi.service.ArticleService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AlbumServiceImpl implements AlbumService {

    @Resource
    private CmfzAlbumDao cmfzAlbumDao;


    @Override
    public Page<CmfzAlbum> selectAll(Integer page, Integer limit) {
        //1.创建一个分页对象 封装分页数据
        Page<CmfzAlbum> albumPage = new Page<>(page, limit);
        //2.使用分页查询的方法
        Page<CmfzAlbum> cmfzBannerPage = cmfzAlbumDao.selectPage(albumPage, null);

        return cmfzBannerPage;
    }

    @Override
    public CmfzAlbum showOne(Integer id) {

        return cmfzAlbumDao.selectById(id);
    }

    @Override
    public void insert(CmfzAlbum cmfzAlbum) {
        try {
            cmfzAlbumDao.insert(cmfzAlbum);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void delete(Integer id) {
        try {
            cmfzAlbumDao.deleteById(id);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void update(CmfzAlbum cmfzAlbum) {
        try {
            cmfzAlbumDao.update(cmfzAlbum,null);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @Override
    public void deleteAll(List<CmfzAlbum> ids) {
        try {
            cmfzAlbumDao.deleteBatchIds(ids);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
